package com.software.graduationproject.modules.sys.entity;

import cn.hutool.core.date.DatePattern;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.v2coding.validate.CreateGroup;
import com.v2coding.validate.UpdateGroup;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.v2coding.mybatis.model.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.util.Date;
import java.math.BigDecimal;

/**
 * SysUser : 系统用户表
 * ---------------------------------------------------------------------------------------------------------------------
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("sys_user")
@ApiModel(value = "SysUser", description = "系统用户表")
public class SysUser extends BaseModel<SysUser> {

    @TableField(value ="username")
    @ExcelProperty(value = "登录账号")
    @ApiModelProperty(value = "登录账号")
    @NotEmpty(groups = {CreateGroup.class, UpdateGroup.class}, message = "登录账号不能为空")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "登录账号长度不能超过255")
    private String username;

    @TableField(value ="password")
    @ExcelProperty(value = "登录密码")
    @ApiModelProperty(value = "登录密码")
    @NotEmpty(groups = {CreateGroup.class, UpdateGroup.class}, message = "登录密码不能为空")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "登录密码长度不能超过255")
    private String password;

    @TableField(value ="nickname")
    @ExcelProperty(value = "用户昵称")
    @ApiModelProperty(value = "用户昵称")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "用户昵称长度不能超过255")
    private String nickname;

    @TableField(value ="mobile")
    @ExcelProperty(value = "手机号码")
    @ApiModelProperty(value = "手机号码")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "手机号码长度不能超过255")
    private String mobile;

    @TableField(value ="id_card")
    @ExcelProperty(value = "身份证号")
    @ApiModelProperty(value = "身份证号")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 18, message = "身份证号长度不能超过18")
    private String idCard;

    @TableField(value ="description")
    @ExcelProperty(value = "备注")
    @ApiModelProperty(value = "备注")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "备注长度不能超过255")
    private String description;

    @TableField(value ="lock_state")
    @ExcelProperty(value = "是否已锁定（0：未锁定；1：已锁定）")
    @ApiModelProperty(value = "是否已锁定（0：未锁定；1：已锁定）")
    private Integer lockState;

    @TableField(value ="lock_time")
    @ExcelProperty(value = "锁定时间")
    @ApiModelProperty(value = "锁定时间")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date lockTime;

    @TableField(value ="unlock_time")
    @ExcelProperty(value = "解锁时间")
    @ApiModelProperty(value = "解锁时间")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date unlockTime;

    @TableField(value ="limitation")
    @ExcelProperty(value = "账号时限")
    @ApiModelProperty(value = "账号时限")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date limitation;

    @TableField("tenant_id")
    @ExcelProperty(value = "租户ID")
    @ApiModelProperty(value = "租户ID")
    private Long tenantId;

}
